ab_glyph
Fast API for loading, scaling, positioning and rasterizing OpenType font glyphs.
use ;
let font = try_from_slice?;
// Get a glyph for 'q' with a scale & position.
let q_glyph: Glyph = font.glyph_id.with_scale_and_position;
// Draw it.
if let Some = font.outline_glyph
no_std
no_std environments are supported using alloc
& libm
.
= { = false, = ["libm"] }
Comparison with rusttype
ab_glyph is a rewrite of rusttype made after I added .otf support for the latter and saw some performance issue's with the rusttype API.
ab_glyph is a more focussed API concentrating on high performance for both .ttf & .otf fonts.
When laying out glyphs into paragraph, ab_glyph is faster than rusttype using .ttf fonts & much faster for .otf fonts.
group ab-glyph rusttype 0.9
----- -------- ------------
layout_a_sentence (exo2-ttf) 1.00 11.1±0.08µs 1.56 17.3±0.14µs
layout_a_sentence (exo2-otf) 1.00 11.1±0.12µs 8.85 98.1±1.17µs
Note: Numbers from May-2020 benchmarks, ab-glyph performance is also expected to have improved since then.